package ngat.oss.simulation.metrics;

import ngat.oss.simulation.*;

import ngat.phase2.*;
import ngat.util.*;

public class RemainingNightsUtilityCalculator implements UtilityCalculator {

    TimingConstraintWindowCalculator tcwc;

    public RemainingNightsUtilityCalculator(TimingConstraintWindowCalculator tcwc) {
	this.tcwc = tcwc;
    }

    public double getUtility(Group group, long time, EnvironmentSnapshot env, ExecutionStatistics hist) {

	TimeWindow window = tcwc.getWindow(group, hist, time);

	int rn = tcwc.countRemainingNights(group, window, time, env, hist);

	//	System.err.println("RTUC: Group: "+group.getName()+" RN="+rn);
	return 1.0/(double)rn;

    }

}
